home *** CD-ROM | disk | FTP | other *** search
- Path: math.ohio-state.edu!usc!usc!not-for-mail
- From: awawda@mirzam.usc.edu (Abu A. Wawda)
- Newsgroups: comp.lang.c
- Subject: How do I modify a character string that's declared as an array of char?
- Date: 22 Feb 1996 16:45:41 -0800
- Organization: University of Southern California, Los Angeles, CA
- Sender: awawda@mirzam.usc.edu
- Distribution: world
- Message-ID: <4gj2nl$840@mirzam.usc.edu>
- NNTP-Posting-Host: mirzam.usc.edu
-
- How do I write a function that can modify a string that was declared
- as an array of characters?
-
- for example:
-
- myfunction(char **s)
- {
- // modify string s
- }
-
- main()
- {
- char mydata[50];
-
- strcpy(mydata,"test string");
- myfunction(&mydata);
- }
-
- this does not seem to work! it works fine if i pass i declare mydata
- as a pointer to a character like this (or dynamically allocate the
- string using a pointer) and pass the address of the pointer:
-
- main()
- {
- char *mydata = "test string";
-
- myfunction(&mydata);
- }
-
- the problem with this is i need to write a function that will modify a
- string created with an array of characters. i can't figure out how do
- to this. please help. thanks!
-
- Abu Wawda
- wawda@scf.usc.edu
- --
- This is my signature.
- Go away.
-